#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os.path
import re
import tornado.database
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import base64
import hashlib

# base
class BaseHandler(tornado.web.RequestHandler):
    @property
    def db(self):
        return self.application.db

    def allow(self,gid):
        if "uid" not in self.__dict__:
            if self.get_secure_cookie("uid") and self.get_secure_cookie("gid")==str(gid):
                self.uid = self.get_secure_cookie("uid")
                self.gid = self.get_secure_cookie("gid")
                self.email = self.get_secure_cookie("email")
            else:
                self.write("Access Denies!")
                self.finish()
